package com.edgar.baselibrary.network.request;

import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.edgar.baselibrary.network.response.VolleyDelegateResponse;

import java.util.Map;

/**
 * Created by edgar on 2016/1/22.
 */
public class VolleyDelegateRequest extends Request<String>{
    private VolleyDelegateResponse mDelegateResponse;
    private IRequest<?> mClientRequest;

    public VolleyDelegateRequest(int method,String url, VolleyDelegateResponse response) {
        super(method, url, response);
        this.mDelegateResponse = response;
    }

    public <T> void setClientRequest(IRequest<T> request){
        this.mClientRequest = request;
    }

    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        if(mClientRequest != null){
            return mClientRequest.getParams();
        }
        return super.getParams();
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        if(mClientRequest != null){
            return mClientRequest.getHeaders();
        }
        return super.getHeaders();
    }

    @Override
    public String getUrl() {
        if(mClientRequest != null){
            return mClientRequest.getUrl();
        }
        return super.getUrl();
    }

    @Override
    protected Response<String> parseNetworkResponse(NetworkResponse response) {
        return null;
    }

    @Override
    protected void deliverResponse(String response) {

    }
}
